package ouyangye.second;

abstract class Employee implements SalaryCalculator {
    private String name;
    private double salary;
    private int workYears;

    public Employee(String name, double salary, int workYears) {
        this.name = name;
        this.salary = salary;
        this.workYears = workYears;
    }

    public abstract void work();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public int getWorkYears() {
        return workYears;
    }

    public void setWorkYears(int workYears) {
        this.workYears = workYears;
    }
}


class Worker extends Employee {
    public Worker(String name, double salary, int workYears) {
        super(name, salary, workYears);
    }

    @Override
    public void addSalary() {
        double originalSalary = getSalary();
        int workYears = getWorkYears();
        double newSalary = originalSalary * 1.1 + workYears * 100;
        setSalary(newSalary);
        System.out.println(getName() + "涨薪后：" + String.format("%.2f", newSalary) + "元");
    }

    @Override
    public void work() {
        System.out.println(getName() + "负责生产工作");
    }

    public void repairEquipment() {
        System.out.println(getName() + "进行设备维修");
    }
}

class Manager extends Employee {

    public Manager(String name, double salary, int workYears) {
        super(name, salary, workYears);
    }

    @Override
    public void addSalary() {
        double originalSalary = getSalary();
        int workYears = getWorkYears();
        double newSalary = originalSalary * 1.2 + workYears * 200;
        setSalary(newSalary);
        System.out.println(getName() + "涨薪后：" + String.format("%.2f", newSalary) + "元");
    }

    @Override
    public void work() {
        System.out.println(getName() + "负责团队管理工作");
    }

    public void manageTeam() {
        System.out.println(getName() + "负责分配工作任务");
    }
}


